TELEVISION PROTOCOL
(The TV picture according to Atari)
For the purposes of Stella programming, a single television
frame consists of 262 horizontal lines, and each line is
divided by 228 clock counts (3.58MHz). The actual TV
picture is drawn line by line from the top down 60 times a
second, and actaully consists of only a portion of the
entire frame (see diag. #1). A typical frame will
consists of 3 vertical sync (VSYNC) lines*, 37 vertical
blank (VBLANK) lines, 192 TV picture lines, and 30 overscan
lines. Ataris research has shown that this pattern will
work on all types of TV sets. Each scan lines starts with
68 clock counts of horizontal blank (not seen on the TV
screen) followed by 160 clock counts to fully scan one line
of TV picture. When the electron beam reaches the end of a
scan line, it returns to the left side of the screen, waits
for the 68 horizontal blank clock counts, and proceeds to
draw the next line below.
All horizontal timing is taken care of by hardware, but the
microprocessor must manually control vertical timing to
signal the start of the next frame. When the last line of
the previous frame is detected, the microprocessor must
generate 3 lines of VSYNC, 37 lines of VBLANK, 192 lines of
actual TV picture, and 30 lines of overscan. Fortunately,
both VSYNC and VBLANK can simply be turned on and off at
the appropriate times, freeing the microprocessor for other
activities during their execution.
* (to signal the TV set to start a new frame)
The actual TV picture is drawn one line at a time by having
the microprocessor enter the data for that line into the
Television Interface Adaptor (TIA) chip, which then
converts the data into video signals. The TIA can only
have data in it that pertains to the line being currently
drawn, so the microprocessor must be one step ahead of
the electron beam on each line. Since one microprocessor
machine cycle occurs every 3 clock counts, the programmer
has only 76 machine cycles per line (228/3 = 76) to
construct the actual picture (actually less because the
microprocessor must be ahead of the raster). To allow more
time for the software, it is customary (but not required)
to update the TIA every two scan lines. The portion of the
program that constructs this TV picture is referred to as
the Kernel, as it is the essence or kernel of the game.
In general, the remaining 70 scan lines (3 for VSYNC, 37
for VBLANK, and 30 for overscan) will provides 5,320
machine cycles (70 lines x 76 machine cycles) for
housekeeping and game logic. Such activities as
calculating the new position of a player, updating the
score, and checking for new inputs are typically done
during this time.